﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;

namespace LucyGrid
{
	/// <summary>
	/// Linq extensions
	/// </summary>
	public static class GridLinq
	{
		/// <summary>
		/// Add extension to collections
		/// </summary>
		/// <typeparam name="TSource"></typeparam>
		/// <typeparam name="TResult"></typeparam>
		/// <param name="source"></param>
		/// <param name="executor"></param>
		/// <returns></returns>
		public static IEnumerable<TResult> AsParallelGrid<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> executor, GridSettings settings = null)
		{
			var grid = new GridMaster(executor.Method, settings);
			return grid.ProcessData<TSource, TResult>(source);
		}
	}
}
